<?php
Yii::app()->clientScript->registerScriptFile($this->adminPath . '/timepicker/js/jquery-1.7.1.min.js',CClientScript::POS_HEAD);
Yii::app()->clientScript->registerScriptFile($this->adminPath."/timepicker/js/jquery-ui-1.8.17.custom.min.js",CClientScript::POS_HEAD);
Yii::app()->clientScript->registerScriptFile($this->adminPath."/js/jquery.validationEngine.js",CClientScript::POS_HEAD);
Yii::app()->clientScript->registerScriptFile($this->adminPath."/js/jquery.validationEngine-zh_CN.js",CClientScript::POS_HEAD);
Yii::app()->clientScript->registerScriptFile($this->adminPath."/js/art-dialog/jquery.artDialog.js",CClientScript::POS_HEAD);
Yii::app()->clientScript->registerScriptFile($this->adminPath."/js/art-dialog/plugins/iframeTools.js",CClientScript::POS_HEAD);

?>
<link rel="stylesheet" type="text/css" href="<?php echo $this->adminPath; ?>/timepicker/css/jquery-ui-1.8.17.custom.css" />
<link rel="stylesheet" type="text/css" href="<?php echo $this->adminPath; ?>/js/art-dialog/skins/blue.css" />
<link rel="stylesheet" type="text/css" href="<?php echo $this->adminPath; ?>/js/validationEngine.jquery.css" />
<style type="text/css">
    .st-labeltext {
        color: #3C5868;
        display: block;
        float: left;
        font-size: 12px;
        line-height: 20px;
        padding-right: 10px;
        padding-top: 3px;
        width: 80px;
    }
    .datepicker-input{
        width: 200px;
    }
</style>

<form id="form"  method="post" >
<div class="st-form-line" style="z-index: 580;">
    <span class="st-labeltext">标题:</span>
    <input type="text" value=""  name="Flash[title]" style="width:300px;margin-bottom: 10px;float: left" id="title" class="st-success-input validate[required,maxSize[50]]"  data-errormessage-range-overflow="标题不得大于50个字" data-errormessage-value-missing="标题不得为空" >
    <div class="clear" style="z-index: 570;"></div>
</div>
<div class="st-form-line" style="z-index: 650;">
    <span class="st-labeltext">幻灯片</span>
    <a original-title="选择图片" href="javascript:uploadifyAction('thumbWarp','thumb'); " style="float: left"  class="icon-button tips">
        <img width="18" height="18" src="<?php echo $this->adminPath; ?>/img/icons/sidemenu/image.png" alt="icon">
    </a>
    <ul id="thumbWarp"></ul>
    <div class="clear" style="z-index: 640;"></div>
</div>
<div class="st-form-line" style="z-index: 580;">
    <span class="st-labeltext">链接地址:</span>
    <input type="text" value="" name="Flash[url]" style="width:400px;margin-bottom: 10px;float: left" id="facilitator" class="st-success-input  validate[maxSize[300]]" data-errormessage-range-overflow="链接地址不得大于300位" >
    <div class="clear" style="z-index: 570;"></div>
</div>
<div class="st-form-line" style="z-index: 580;">
    <span class="st-labeltext">排序:</span>
    <input type="text" value="0" name="Flash[listorder]" style="width:50px;margin-bottom: 10px;float: left" id="listorder" class="st-success-input validate[required,custom[number]]" data-errormessage-value-missing="排序不得为空"  data-errormessage-custom-error="请填写数字" >
    <div class="clear" style="z-index: 570;"></div>
</div>
<div class="st-form-line button-box" style="z-index: 460;">
    <input type="submit" class="st-button" value="保存" id="submit" name="button">
</div>
</form>

<script type="text/javascript">
    //缩略图上传
    function uploadifyAction(Warp,Name) {
        art.dialog.data('Warp',Warp);
        art.dialog.data('Name',Name);
        art.dialog.open(
            '<?php echo Yii::app()->createAbsoluteUrl("admin/uploadify/basic"); ?>',
            {
                title:'附件上传',
                lock: false,
                width: 600,
                height: 300,
                ok: function () {
                    var fileListWarp = art.dialog.data('fileListWarp');
                    $("#"+Warp).append(fileListWarp);
                    this.close();
                    return false;
                },
                cancelVal: '取消',
                cancel: true
            }

        );
    }
    function uploadifyRemove(fileId,attrName){
        if(confirm('本操作不可恢复，确定继续？')){
            $.post(
                "<?php echo Yii::app()->createAbsoluteUrl("admin/uploadify/remove"); ?>",
                {imageId:fileId},
                function(res){
                    $("#"+attrName+fileId).remove();
                },
                'json'
            );
        }
    }
    $(function(){
        $("#form").validationEngine({
            ajaxFormValidation: true,
            ajaxFormValidationURL: '<?php echo Yii::app()->createAbsoluteUrl('admin/front/flashAdd'); ?>',
            ajaxFormValidationMethod: "post",
            //validateNonVisibleFields:true,//验证隐藏字段
            onBeforeAjaxFormValidation: function (form, options) {
                art.dialog.Talert('数据交互中ing', 5);
            },
            onAjaxFormComplete: function (status, form, json, options) {
                if (json['status'] == 1) {
                    art.dialog.Talert(json['message']);
                    var win = art.dialog.open.origin;
                    win.location.reload();
                } else {
                    art.dialog.Talert(json['message']);
                }
            }

        });
    });
</script>
